• 0 Votes
    3 Posts
    83 Views
    T
    @jcaron Thanks for the clarification. Okay, Then how about the second part of my question? If I import a library, does the whole library (including unused functions) get loaded into / waste memory? Thanks, Troy
  • different memory size

    LoPy memory size
    3
    0 Votes
    3 Posts
    566 Views
    C
    @ltn22 your are calling this method not on a bare metal system. There is an operating system running in the background and on top of it runs python. Each of them needs some memory to run. You can try to disable all radio devices, background tasks and place the your script in main.py to get rid of different timings by typing. But even your chance to see the same amount of free memory is low. There will be always small differences in the state of your LoPys which can result in a different memory usage. How well the collect can clean up your unused memory depends on the implementation. You can try to call collect multiple times and wait between the calls. But each additonal (high level) statement may result in a different state of the whole system. If you have trouble to get free memory for storing large arrays, there will be another problem. Fragmentation. mem_free may show you enough memory, but most likely this memory will not be available in one huge chunk. There will be a mixture of small and huge blocks depending on what was running before and if the garbage collector is able to move still allocated objects inside the memory.